package com.hbnu.test.www.net;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class TCP_server03_reverse {
    public static void main(String[] args) {
        try (ServerSocket serverSocket = new ServerSocket(6666);) {
            Socket socket = serverSocket.accept();
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            while(true){
                String receivedata = in.readLine();
                System.out.println("客户端发来的消息:" + receivedata);
                receivedata = receivedata.toUpperCase();
                out.write(receivedata);
                out.newLine();
                out.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
